package xin.marcher.wind.process.controller.tradeplatform;

import org.springframework.web.bind.annotation.*;
import xin.marcher.wind.process.domain.request.TradePlatformProcessRequest;
import xin.marcher.wind.process.domain.vo.TradePlatformProcessVO;
import xin.marcher.wind.process.service.TradePlatformProcessService;

import javax.annotation.Resource;

/**
 * 交易平台业务流程定义管理
 *
 * 
 * @version 1.0
 */
@RestController
@RequestMapping("/trade-platform/process")
public class TradePlatformProcessController {

    @Resource
    private TradePlatformProcessService tradePlatformProcessService;

    /**
     * 新增一个流程定义
     * @param tradePlatformProcessRequest
     * @return
     */
    @PostMapping
    public TradePlatformProcessVO addProcess(@RequestBody TradePlatformProcessRequest tradePlatformProcessRequest) {
        return tradePlatformProcessService.addProcess(tradePlatformProcessRequest);
    }

    /**
     * 查询一个流程定义
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public TradePlatformProcessVO getProcess(@PathVariable("id") Long id) {
        return tradePlatformProcessService.getProcess(id);
    }

    /**
     * 编辑一个流程定义
     * @param id
     * @param tradePlatformProcessRequest
     * @return
     */
    @PutMapping("/{id}")
    public TradePlatformProcessVO editProcess(@PathVariable("id") Long id, @RequestBody TradePlatformProcessRequest tradePlatformProcessRequest) {
        return tradePlatformProcessService.editProcess(id, tradePlatformProcessRequest);
    }


    /**
     * 删除一个流程定义
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Boolean deleteProcess(@PathVariable("id") Long id) {
        return tradePlatformProcessService.deleteProcess(id);
    }

}